home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_0799 / 513 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  1.7 KB

  1. Date: Sat, 25 Sep 93 19:45:55 -0400
  2. From: "Nicholas S Castellano" <entropy@terminator.rs.itd.umich.edu>
  3. To: mint@terminator.rs.itd.umich.edu
  4. Subject: read() and POSIX compliance
  5.  
  6.  
  7. I've been putting some thought into making the MiNT library's read()
  8. function POSIX compliant.
  9.  
  10. As it currently stands, the call will return 0 for a read on a device
  11. if the device is positioned at end-of-file, or if the file handle is
  12. marked O_NDELAY and no data is ready.
  13.  
  14. POSIX introduces the O_NONBLOCK flag which causes the read() to return
  15. -1 with errno set to EAGAIN, when the file has no data available but
  16. is not an end-of-file condition.
  17.  
  18. I'm thinking along these lines:
  19.   -call Fcntl(fd, &nbytes, FIONREAD)
  20.   -call Fread(...)
  21.   -if Fread() returns 0:  then if nbytes is 0 return -1 with errno =
  22.     EAGAIN, otherwise return 0 signifying end-of file.
  23.  
  24. This seems valid for the TOS filesystem (since it always gives 1 for
  25. FIONREAD it will never give EAGAIN) and for the pipefs (which will
  26. give -1 for FIONREAD at end-of-file [that is, when the other side of
  27. the pipe is closed] and 0 if there is just no data ready).
  28.  
  29. This reasoning breaks down, however, in the case of a device such as
  30. the shmfs.  This device will give 0 bytes for an FIONREAD when at
  31. end-of-file, so using the above scheme would mean a non-blocking
  32. read() on shmfs would never return 0.
  33.  
  34. I'm a bit stumped.  I think it will be necessary to define the exact
  35. action of FIONREAD at end-of-file for device drivers in some
  36. consistent manner in order to make it possible to distinguish EOF from
  37. a lack of available data.
  38.  
  39. Or am I just overlooking something?
  40.  
  41. Cheers,
  42. entropy
  43.  
  44. --
  45. entropy -- it's not just a good idea, it's the second law.
  46. Personal mail:      entropy@gnu.ai.mit.edu
  47. MiNT library mail:  entropy@terminator.rs.itd.umich.edu
  48.  
  49.  
  50.